<!DOCTYPE html>
<body>
<script src="../../../resources/js-test.js"></script>
<label><input type="checkbox">Label for a checkbox</label>
<script>
description('Event order for a labeled control should be "focus" then "change"');
var label = document.querySelector('label');
var checkbox = document.querySelector('input');
var focusCount = 0;
var changeCount = 0;
checkbox.addEventListener('focus', function() {
    debug('"focus" event has been dispatched.');
    focusCount++;
    shouldBe('changeCount', '0');
}, false);
checkbox.addEventListener('change', function() {
    debug('"change" event has been dispatched.');
    changeCount++;
    shouldBe('focusCount', '1');
}, false);
label.click();
label.remove();
</script>
</body>
